﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using EAD;

namespace RAW
{
    public class ReadAndWrite
    {
        EnAndDecrypt EAD = new EnAndDecrypt();
        //đọc file theo dạng mã hóa Info
        public string ReadFileInfo(string pathFile)
        {
            string temp = "";
            StreamReader reader = File.OpenText(pathFile);
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                temp += line;
            }
            reader.Close();
            return EAD.DecryptInfo(temp);
        }

        //đọc file mã hóa dạng test
        public string ReadFileTest(string pathFile)
        {
            string temp = "";
            StreamReader reader = File.OpenText(pathFile);
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                temp += line;
            }
            reader.Close();
            return EAD.DecryptTest(temp);
        }

        //đọc file mã hóa dạng pass
        public string ReadFilePass(string pathFile)
        {
            string temp = "";
            StreamReader reader = File.OpenText(pathFile);
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                temp += line;
            }
            reader.Close();
            return EAD.DecryptPass(temp);
        }

        //Viết vào file dạng mã hóa Info
        public void WriteFileInfo(string pathFile, string text)
        {
            StreamWriter wr = File.CreateText(pathFile);
            wr.Write(EAD.EncryptInfo(text));
            wr.Close();
        }

        //Viết vào file dạng mã hóa Test
        public void WriteFileTest(string pathFile, string text)
        {
            StreamWriter wr = File.CreateText(pathFile);
            wr.Write(EAD.EncryptTest(text));
            wr.Close();
        }

        //Viết vào file dạng mã hóa Pass
        public void WriteFilePass(string pathFile, string text)
        {
            StreamWriter wr = File.CreateText(pathFile);
            wr.Write(EAD.EncryptPass(text));
            wr.Close();
        }
    }
}
